--TEST--
Check behavior with AppendIterator data
--FILE--
<?php
/**
 * Test file to iterate over n OuterIterator built using AppendIterator
 *
 * PHP version 5
 *
 * @category  Stream
 * @package   Stream_Iterate
 * @author    Philippe Jausions <Philippe.Jausions@11abacus.com>
 * @copyright 2008 by 11abacus / Philippe Jausions
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @link      http://pear.11abacus.com/package/Stream_Iterate
 */

/**
 * Required package to test
 */
require_once 'Stream/Iterate.php';

/**
 * Main
 */

// Register protocol
stream_wrapper_register('foreach', 'Stream_Iterate');

$data1 = new ArrayObject(array('abc', 123));
$data2 = new ArrayObject(array('xyz', 987));

$iterator = new AppendIterator();
$iterator->append($data1->getIterator());
$iterator->append($data2->getIterator());

// Let's define a callback to convert the data into a string that will be
// piped into the stream (any valid callback will do)
$callback = create_function('$key, $value',
                            'return $key."=".$value."\r\n";');

// Create the context for the stream
$context = stream_context_create(array('foreach' => array(
                                                 'subject'  => &$iterator,
                                                 'toString' => $callback)));
// Open the stream
$fp = fopen('foreach://subject', 'r', false, $context);

set_time_limit(1);
if (!$fp) {
    echo 'Could not open path';
    return;
}
while (!feof($fp)) {
    echo fgets($fp);
}
fclose($fp);

?>
--EXPECT--
0=abc
1=123
0=xyz
1=987